<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>结果面板</title>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
	</head>
	
	<body>
		<div style="width: 520px; height: 340px; border: 1px solid gray" id="container"></div>
		<div>
			<li>
				省份：
				<input type="text" name="province" value="" readOnly="true" id="province"/>
			</li>
			<li>
				城市：
				<input type="text" name="city" value="" readOnly="true" id="city"/>
			</li>
			<li>
				区县：
				<input type="text" name="district" value="" readOnly="true" id="district"/>
			</li>
			<li>
				街道：
				<input type="text" name="street" value="" readOnly="true" id="street"/>
			</li>
			<li>
				门牌号：
				<input type="text" name="streetNumber" value="" readOnly="true" id="streetNumber"/>
			</li>
		</div>
	</body>

	<script type="text/javascript">
		var map = new BMap.Map("container");
		map.centerAndZoom(new BMap.Point(116.404, 39.915), 15);
		map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
		map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
		map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
		
		function myFun(result){
		    var cityName = result.name;
		    map.setCenter(cityName);
		}
		var myCity = new BMap.LocalCity();
		myCity.get(myFun);
		
		var gc = new BMap.Geocoder();    
		
		map.addEventListener("click", function(e){        
		    var point = e.point;
		    gc.getLocation(point,function(rs){
		        var addComp = rs.addressComponents;
		        if(confirm(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber)){
		        	map.clearOverlays();
		        	map.addOverlay(new BMap.Marker(point));
		        	document.getElementById('province').value=addComp.province;
		        	document.getElementById('city').value=addComp.city;
		        	document.getElementById('district').value=addComp.district;
		        	document.getElementById('street').value=addComp.street;
		        	document.getElementById('streetNumber').value=addComp.streetNumber;
		        }
		    });        
		});
	</script>

</html>
